package at.moop.up;

import java.io.IOException;

import android.content.Context;
import android.net.Uri;
import android.os.AsyncTask;

public class PhotoSubmitterTask extends AsyncTask<Uri, String, Integer> {
	private Context context;
	private OnPhotoSubmittedListener osl;
	
	public PhotoSubmitterTask(Context context){
		this.context = context;
	}
	
	public PhotoSubmitterTask(Context context, OnPhotoSubmittedListener osl){
		this.context = context;
		this.osl = osl;
	}

	@Override
	protected Integer doInBackground(Uri... params) {
		try {
			return PhotosphereSubmitter.submit(params[0], context);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return -100;
		}
	}
	
	@Override
	protected void onPostExecute(Integer i){
		if(osl != null){
			osl.onPhotoSubmitted(i);
		}
	}

}
